#include "tower.h"
#include "tower_base.h"

#include "config.h"
#include <QtDebug>

Tower::Tower(const QString& type,int a, int b):tower_base(a,b)
{
    if(type=="attacker1"){
        this->Width=ATTACKER_WIDTH;
        this->Height=ATTACKER_HEIGHT;
        this->_mPix.load(attacker1);
        this->fireInterval=fireInterval = ATTACKER_FIRE_INTERVAL;
    }
    if(type=="attacker2"){
        this->Width=ATTACKER1_WIDTH;
        this->Height=ATTACKER1_HEIGHT;
        this->_mPix.load(attacker2);
        this->fireInterval=fireInterval = ATTACKER1_FIRE_INTERVAL;
    }
    if(type=="attacker3"){
        this->Width=ATTACKER2_WIDTH;
        this->Height=ATTACKER2_HEIGHT;
        this->_mPix.load(attacker3);
        this->fireInterval=fireInterval = ATTACKER2_FIRE_INTERVAL;
    }
    if(type=="attacker4"){
        this->Width=ATTACKER3_WIDTH;
        this->Height=ATTACKER3_HEIGHT;
        this->_mPix.load(attacker4);
        this->fireInterval=fireInterval = ATTACKER3_FIRE_INTERVAL;
    }
    if(type=="attacker5"){
        this->Width=ATTACKER4_WIDTH;
        this->Height=ATTACKER4_HEIGHT;
        this->_mPix.load(attacker5);
        this->fireInterval=fireInterval = ATTACKER4_FIRE_INTERVAL;
    }
    this->coolDown=this->fireInterval;
    this->velocity_rotation = ATTACKER_VELOCITY_ROTATION;
    this->angle=180;
    this->Tower_Type=type;
    this->_mRect.setRect(this->x-this->Width/2,this->y,this->Width,this->Height);
}

int Tower::GetWidth()
{
    return this->Width;
}

int Tower::GetHeight()
{
    return this->Height;
}

QRect Tower::GetRect()
{
    return this->_mRect;
}

QString Tower::GetType()
{
    return this->Tower_Type;
}

QPixmap &Tower::GetPix()
{
    return this->_mPix;
}

Tower::~Tower()
{
    qDebug()<<"delete Tower"<<endl;
}

float Tower::GetAngle()
{
    return this->angle;
}

void Tower::SetAngle(double m_angle)
{
    this->angle=m_angle;
}

float Tower::Get_velocity_rotation()
{
    return this->velocity_rotation;
}

void Tower::Set_Angle_Ready(bool flag)
{
    this->_angle_ready=flag;
}

bool Tower::Get_Angle_Ready()
{
    return this->_angle_ready;
}

bool Tower::IfFireReady()
{
    return this->fireReady;
}

void Tower::FireCoolDown()
{
    this->coolDown-=20;
    if(this->coolDown<=0){
        this->fireReady=true;
    }
}

void Tower::ResetCoolDown()
{
    this->fireReady=false;
    this->coolDown=this->fireInterval;
}

void Tower::UpDataStatu()
{
    
}
